<?php

class Shipping{

	/**
	 * 添加
	 *
	 * @param unknown_type $name
	 * @param unknown_type $parent
	 * @param unknown_type $ord
	 */
	function add($data){
		
		$m = M('Shipping');
		//返回自增id
		$id = $m->add($data);
		
		return $id;
	}
	
	/**
	 * 修改
	 *
	 * @param unknown_type $id
	 * @param unknown_type $upItems
	 * @return unknown
	 */
	function update($id,$upItems){
		$m = M('Shipping');
		return $m -> where('shipping_id='.$id)->save($upItems);
	}
	
	function get_by_id($id){
		$m = M('Shipping');
		return $m -> getByShippingId($id);
	}

	function lists(){
		
		$m = M('Shipping');
		return $m->order('shipping_id ASC')
		->select();
	}
	
	function shipping_name_map(){
		
		$shippings = $this-> lists();
		
		$map = array();
		foreach ($shippings as $i => $s){
			$map[$s['shipping_name']] = $s['shipping_id'];
		}
		
		return $map;
	}

}